package com.wuchao.convert.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.socket.config.annotation.*;
import org.springframework.web.socket.server.standard.ServerEndpointExporter;

/**
 * @author WuChao
 * @version 1.0
 * @date 2020/4/7 9:38
 */
@Configuration
@EnableWebSocketMessageBroker//注解使用STOMP协议传输基于代理消息
public class WebSocketConfig extends AbstractWebSocketMessageBrokerConfigurer
{
    @Bean
    public ServerEndpointExporter serverEndpointExporter() {
        return new ServerEndpointExporter();
    }

    @Override
    public void registerStompEndpoints(StompEndpointRegistry registry) {
        registry.addEndpoint("/MyServer/**").setAllowedOrigins("*").withSockJS();
    }
}
